<?php

class includes {
	
	static function loadAll() {
		includes::loadConfig();
		includes::loadClasses();
		includes::loadModels();
	}
	
	static function loadConfig() {
		includes::loadDir('config');
	}
	
	static function loadClasses() {
		includes::loadDir('classes/core');
		includes::loadDir('classes/formats');
		includes::loadDir('classes/helpers');
		includes::loadDir('classes/apis');
//		includes::loadDir('classes/lib/musicbrainz');
		includes::loadDir('classes/lib/phpquery');
//		includes::loadDir('classes/lib/id3v1');
	}
	
	static function loadModels() {
		includes::loadDir('models');
	}
	
	static function loadDir($dir) {
		$includes = scandir($dir.'/');
		foreach ($includes as $file) {
			self::loadFile($dir, $file);
		}
	}
	
	static function loadFile($dir, $file) {
		$name = null;
		if (substr($file,-4,4) == ".php") {
			$name = str_replace('.php','',$name);
			if (!class_exists($name)) {
				include_once($dir.'/'.$file);
			}
		}
	}

}

?>